package com.example.academicsystem.server.controller.grade;

import com.example.academicsystem.pojo.dto.GradeCourseOrderDto;
import com.example.academicsystem.result.PageResult;
import com.example.academicsystem.result.Result;
import com.example.academicsystem.server.service.GradeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/grade")
@Api("grade order")
public class GradeOrderController {
    @Autowired
    private GradeService gradeService;

    /**
     * 分页查询某一课程的所有学生的排名
     * */
    @PostMapping("/course/order")
    @ApiOperation("courseId 和courseName任选一个就行")
    public Result<PageResult> gradeOrderByCourse(@RequestBody GradeCourseOrderDto gradeCourseOrderDto){
        log.info("grade sort by course");
        PageResult pageResult = gradeService.gradeOrderByCourse(gradeCourseOrderDto);
        return Result.success(pageResult);
    }
}
